#ifndef QQTSYSTEMINFO_LINUX_H
#define QQTSYSTEMINFO_LINUX_H

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <QObject>

#include "qqtsysteminfo.h"
class QQtSystemInfo;
class QQtSystemInfoPrivate
{
public:
    explicit QQtSystemInfoPrivate ( QQtSystemInfo* parent = 0 ) : q_ptr ( parent ) {

    }
    ~QQtSystemInfoPrivate() {

    }
    // read the linux config files to get system info
    bool getOSInfo() {
        FILE* fp = fopen ( "/proc/version", "r" );
        if ( NULL == fp )
            printf ( "failed to open version\n" );
        char szTest[1000] = {0};
        while ( !feof ( fp ) ) {
            memset ( szTest, 0, sizeof ( szTest ) );
            fgets ( szTest, sizeof ( szTest ) - 1, fp ); // leave out \n
            printf ( "%s", szTest );
        }
        fclose ( fp );
    }

    bool getCPUInfo(TCPUTable&) {
        FILE* fp = fopen ( "/proc/cpuinfo", "r" );
        if ( NULL == fp )
            printf ( "failed to open cpuinfo\n" );
        char szTest[1000] = {0};
        // read file line by line
        while ( !feof ( fp ) ) {
            memset ( szTest, 0, sizeof ( szTest ) );
            fgets ( szTest, sizeof ( szTest ) - 1, fp ); // leave out \n
            printf ( "%s", szTest );
        }
        fclose ( fp );
    }

    bool getMEMInfo(TMemTable&) {
        FILE* fp = fopen ( "/proc/meminfo", "r" );
        if ( NULL == fp )
            printf ( "failed to open meminfo\n" );
        char szTest[1000] = {0};
        while ( !feof ( fp ) ) {
            memset ( szTest, 0, sizeof ( szTest ) );
            fgets ( szTest, sizeof ( szTest ) - 1, fp );
            printf ( "%s", szTest );
        }
        fclose ( fp );
    }
    bool getDISKInfo ( TDiskTable& diskInfo ) {

    }

private:
    Q_DECLARE_PUBLIC ( QQtSystemInfo )
    QQtSystemInfo* q_ptr;
};

#endif //QQTSYSTEMINFO_LINUX_H
